﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SettingEvalDefault.aspx.cs" Inherits="Credit_Teacher_RuleSettings_SettingEvalDefault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>设置德育评价</title>
     <link href="../../Common/css/main.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .noneClick {
            cursor: default;
        }
    </style>

    <script type="text/javascript" src="../../Common/js/jquery.js"></script>

    <script type="text/javascript" src="../../Common/js/common.js"></script>
    
    <script type="text/javascript">

var currHistoryId = 0; //当前编辑状态的学分评估id
var currCauseId = 0;//当前学科id
var type=1//当前是StuCauseEval
var currEvalType = 2;//当前学科id

//-----------------------------------------------------------------------保存 
 var arrId = new Array();
function ShowSaveWindow()
{
    arrId = new Array();
    var table = document.getElementById('table');
    if(table != null)
    {
        for(var i = 1 ; i< table.rows.length;i++)
        {
            var row = table.rows[i];
            //记录要保存的historyId
           
            if(row.cells[3].all[0].checked  == true && row.cells[2].all[0].state == 0)
            {
                arrId.push(row.id);
            }
        }
    } 
    if(arrId.length == 0)
    {
         showNoticMsg('btnSave','您还未选定要保存的项目, 或者您所选定的项目已经经过确认.',-75,15); 
    }
    else 
    {
        showConfirmBox("确定生效", "保存后生效后，您将不能再对此进行修改，确认生效？", Save, null);
    }
}

function Save()
{
   var table = document.getElementById('table');
   if(table != null)
   {
        var b = false;
        for(var i = 1 ; i< table.rows.length;i++)
        {
            var row = table.rows[i];
            if(row.cells[3].all[0].checked == true)
            {
                var status = row.cells[1].id;
                if(status != null)
                {
                    if(Number(status) >=0)
                    {
                       b = true;
                    }
                    
                    else
                    {
                        b = false;
                        break;
                    }
                }
            }
        }
        if(b == false)
        {
            showMassgeBox("提示","还有未录入的科目,请编辑录入后再确定",1,null);
        }
        else
        {
            PageMethods.SaveSure(arrId,function(succ){
                if(succ > 0)
                { 
                   //TODO:更改default页面的iscan字段，以及在载入界面时，根据该字段值，对界面disabled属性设置,并且添加提示描述
                   //this.parent.canStart = true;
                    showMassgeBox("提示","保存成功",1,null);
                    Bind();
                }
                else
                {
                    showMassgeBox("提示","保存失败",1,null);
                }
             },function(err){
              showMassgeBox("提示",err._message,1,null);
            }); 
        } 
   }
} 
        
//-----------------------------------------------------------------------弹出编辑页面        
function LoadEditPage(row, state)
{ 
    var rid = row.id;
    var causeId = row.cells[0].id;
    this.parent.frames["mainFrame"].location.href = "SettingEval.aspx?historyId="+rid+"&causeId="+causeId+"&state="+state;
}

function leftNav(obj, nav) 
{
        removeActiveStyle();
        obj.parentNode.className = "active";
        
        //TODO:重新载入table数据
     
}
/**
 移除active样式
*/
function removeActiveStyle() {
    var liList = document.getElementsByTagName("li");
    for (var i=0; i<liList.length; i++) {
        liList[i].className = "";
    }
}

//选中行高亮
function SetHightLight(obj)
{
    if(obj != null) 
        obj.style.backgroundColor = "#fffccf";
        
    var table = document.getElementById('table');
    for(var i =0 ; i < table.rows.length;i++)
    {
        var row = table.rows[i];
        if(row != null && row.rowIndex != obj.rowIndex)
        {
            row.style.backgroundColor = "#ffffff";
        }
    }
    
    currHistoryId = obj.id;
    currCauseId = obj.cells[0].id;
} 

function Bind()
{
    arrId = new Array();
    document.getElementById('btnBind').click();
}

function ShowDaySetting()
{
    ShowPopForm('timeSetting', 'timeSettingTitle', '学分录入时间限制');
    // 获取dayLimit
    document.getElementById("dayLimit").value = document.getElementById("<%=txtDayLimit.ClientID%>").value;
}

    function OnInputKeyPress()
    {
        return event.keyCode>=48&&event.keyCode<=57;
    }

function SetDayLimit()
{
    // 设置dayLimit
    PageMethods.SaveDayLimit(parseInt(document.getElementById("dayLimit").value),function(succ){
                if(succ > 0)
                { 
                   //TODO:更改default页面的iscan字段，以及在载入界面时，根据该字段值，对界面disabled属性设置,并且添加提示描述
                   //this.parent.canStart = true;
                    document.getElementById("<%=txtDayLimit.ClientID%>").value = document.getElementById("dayLimit").value;
                    ClosePopForm('timeSetting');
                }
                else
                {
                    showMassgeBox("提示","保存失败",1,null);
                }
             },function(err){
              showMassgeBox("提示",err._message,1,null);
            }); 
}

    </script>
</head>
<body>
    <div style="overflow-y: auto; overflow-x: none; height: 98%;">
        <form id="form1" runat="server">
            <div class="mainWarp">
                <div class="pageBody" style="height: 96%;">
                    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
                    </asp:ScriptManager>
                    <h3><label><%=Common.ConvertYearAndTerm(SchoolCommon.Sch_SchoolInfo.SchoolYear,SchoolCommon.Sch_SchoolInfo.SchoolTerm)%>各科日常评分规则一览表</label></h3>
                    <ul class="butList">
                        <li>
                            <input type="button" value="确认生效" class="commonBut" id="btnSave" onclick="ShowSaveWindow();"/>
                            <label id="lblDepict"></label>
                        </li>
                        <li>
                            <a href="#" onclick="ShowDaySetting();">设置学分录入时间限制</a>
                        </li>
                   </ul>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:Repeater ID="Repeater1" runat="server">
                                <HeaderTemplate>
                               
                                <div style="overflow-y: auto; overflow-x: none; height: 90%;">
                                    <table id="table" class="useList" style="width: 95%">
                                        <tr >
                                            <th style="text-align: left; padding-left: 5px;">
                                                科目</th>
                                            <th style="text-align: left; padding-left: 5px;">
                                                状态</th>
                                            <th>编辑</th> 
                                            <th>
                                                 </th>
                                          
                                </HeaderTemplate>
                                <ItemTemplate> 
                                        <tr onclick="SetHightLight(this);" id="<%# Eval("RID")%>">
                                            <td id="<%# Eval("CauseId") %>" style="text-align: left; padding-left: 5px;"><%# Eval("CauseName") %></td>
                                             <td id="<%# Eval("Status") %>" style="text-align: left; padding-left: 5px;"><%# Common.ConvertStatus((int)Eval("Status")) %></td> 
                                            <td><a href="#" state="<%# Eval("Status") %>" onclick="LoadEditPage(this.parentElement.parentElement, state);"><%# Eval("Status").ToString() == "1" ? "查看" : "编辑" %></a></td>
                                            <td><input type="checkbox" valueid="<%# Eval("RID")%>"/></td><%----%>
                                        </tr>
                                 </ItemTemplate>
                                <FooterTemplate> 
                                    </table></div>
                                   
                                 </FooterTemplate>
                            </asp:Repeater> 
                             
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnBind" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                        <%--服务器端控件层--%>
                    <div style="display: none;">
                        <asp:Button runat="server" ID="btnBind" OnClick="btnBind_Click1"  />
                            <asp:TextBox runat="server" ID="txtDayLimit">
                            </asp:TextBox>
                    </div>
                <!-- 学分录入时间限制 -->
                <div id="timeSetting" class="layoutWarp" style="display: none; width: 340px; height: 168px;">
                    <div class="title">
                        <span id="timeSettingTitle"></span><a title="关闭" onclick="ClosePopForm('timeSetting');">
                            关闭</a>
                    </div>
                    <table border="0" class="layoutTable" style="width:300px; height: 120px;">
                        <tr>
                            <td>
                                在次月的<input id="dayLimit" onkeypress="OnInputKeyPress();" style=" width:40px;"/>天前, 可以录入或修改上个月学分.
                                <td>
                        <tr>
                            <td colspan="2">
                                <div style="text-align:center;">
                                    <input type="button" class="commonBut" id="btnTimeSettingOK"
                                        onclick="SetDayLimit();" value="确定" />
                                    <input type="button" class="commonBut" id="btnTimeSettingCacel"
                                        onclick="ClosePopForm('timeSetting');" value="取消" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <!-- END -->
                </div>
            </div>
        </form>
    </div>
</body>
</html>